package extendsindex;

import java.beans.JavaBean;

public class test {
    public static void main(String[] args) {
       /*
       *多态
       *一个对象有多重形态
       * */
         ZI z1=new ZI();
         z1.nameMethod();
         FU z2=new ZI();  //1 有继承关系/实现关系  2 父类引用了子类的对象
        //3 子类继承父类的成员方法必须要重写(Override);
        //Override  方法重写
        //父类的成员方法被(final prviate static)后子类无法方法重写;
        //

    }
}
class FU{
    public int age;
    public String name;

    public int getAge() {
        return age;
    }
   private void method(){
       System.out.println("method");
   }
   public void eat(){
       System.out.println("吃饭");
   }
    public void setAge(int age) {
        this.age = age;
    }

    FU(){

    }
    public FU(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
class ZI extends FU{
    //jvm自带了空参的构造
    public String name;
    public int age;
    public ZI(){
        super();
    }
    public ZI(int age,String name){
        super(age,name);
    }
    @Override
    public void eat(){
        System.out.println("吃炸鸡");
    }
    public  void nameMethod(){
        this.eat();
        super.eat();
        String name="zishow";
        System.out.println(name);
        System.out.println(this.name);//本类成员变量
        System.out.println(super.name);//父类的成员变量
    }

}
